<?php include_once $_SERVER["DOCUMENT_ROOT"] . "/Treinamento/controller/IndexController.php"; ?>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Treinamento - index</title>
        <style type="text/css">
            body{
                text-align: center;
            }
            form{
                text-align: left;
            }
            input{
                position: relative;
            }

            table{
                width: 300px;
            }

            th{
                background-color: #ccc;
            }

            a{
                text-decoration: none;
            }
        </style>
    </head>
    <body>
        <form action="../controller/IndexController.php?action=salvar" method="POST">
            <hr/>
            Nome.: <input type="text" name="inNome" />
            <br/><br/>
            Descricao.: <input type="text"  name="inDescricao"/>
            <br/><br/>
            <input type="submit" />
            <br/><br/>
            <hr/>
        </form>
        <div>
            <table>                
                <th> ID </th>
                <th> Nome </th>
                <th> Descrição </th>
                <th> Ações </th>
                <?php
                $controle = new IndexController("");
                $list = $controle->getList();

                foreach ($list as $registro => $coluna) {
                    echo "<tr>";
                    foreach ($coluna as $atributo => $valor) {
                        echo "<td>";
                        echo $valor;
                    }
                    echo "</td>";
                    ?>
                    <td>
                        <a href="../controller/IndexController.php?action=find&id=<?= $coluna["id"] ?>"> o </a>  
                        <a href="../controller/IndexController.php?action=drop&id=<?= $coluna["id"] ?>"> x </a> 
                    </td>
                    <?php
                }
                echo "</tr>";
                ?>

            </table>
        </div>
    </body>
</html>
